package com.ccb.jyzx.expand.tiantouonline.controller;

import com.ccb.jyzx.expand.tiantouonline.bean.Dict;
import com.ccb.jyzx.expand.tiantouonline.bean.DictTag;
import com.ccb.jyzx.expand.tiantouonline.bean.vo.DictVo;
import com.ccb.jyzx.expand.tiantouonline.service.DictTagService;
import com.ccb.jyzx.expand.tiantouonline.view.result.Result;
import com.ccb.jyzx.expand.tiantouonline.view.result.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @projectName: extend
 * @author: jianghaolin
 * @date: 2019/11/21
 * @version: 1.0
 */
@Controller
@RequestMapping("/tto/dict_tag")
@Api(tags = "标签操作相关接口")
public class DictTagController {

    @Autowired
    private DictTagService dictTagService;

    @ResponseBody
    @PostMapping(value = "findAllByLab",consumes = "application/json;charset=UTF-8")
    @ApiOperation(value = "根据栏目获取标签", notes = "根据栏目获取标签")
    private Result findAllByLab(@RequestBody DictVo vo){
        if(vo == null || StringUtils.isEmpty(vo.getDictCode())){
            return ResultUtil.error("未接收到参数");
        }
        String labCode = vo.getDictCode();
        List<DictTag> list = dictTagService.findAllByLab(labCode);
        return ResultUtil.success(list);
    }
}
